#ifndef PRICEDELEGATE_H
#define PRICEDELEGATE_H

#include <QItemDelegate>
#include <Proveider.h>

namespace ecocity
{

class ProductsModelDelegate : public QItemDelegate
{
    Q_OBJECT

public:

    ProductsModelDelegate( const std::vector< Proveider >& proveiders,
                           QObject *parent = 0 );

signals:

    void price_changed( QAbstractItemModel* model,
                        const QModelIndex& index,
                        float price ) const;

    void index_price_type_changed( QAbstractItemModel* model,
                                   const QModelIndex& index,
                                   const QString& price_type ) const;

private:

    void paint( QPainter *painter, const QStyleOptionViewItem& option,
                const QModelIndex& index ) const;

    QWidget* createEditor( QWidget *parent, const QStyleOptionViewItem &option,
                           const QModelIndex &index) const;

    void setEditorData( QWidget *editor, const QModelIndex &index ) const;
    void setModelData( QWidget *editor, QAbstractItemModel *model,
                       const QModelIndex &index) const;
private slots:

    void commitAndCloseSpinBox( );
    void commitAndCloseComboBox( );

private:

    QString decorate_price_index( const QModelIndex& price_index ) const;

private:

    std::vector< Proveider > m_proveiders;
};

}      // namespace ecocity

#endif // PRICEDELEGATE_H
